package cn.exrick.pojo;

import java.math.BigDecimal;

import lombok.Data;

/**
 * 价格优惠
 */
@Data
public class TbPreferential extends BasePojo {
    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private BigDecimal money;//限制条件:满xxx元

    private Integer num;//限制条件:满xxx件

    private BigDecimal total;//总额减

    private BigDecimal price;//单价减

    public String getContent() {
        String result = "";
        if (money != null && money.doubleValue() > 0) {
            result += ("满" + money.doubleValue() + "元");
        }
        if (num != null && num > 0) {
            result += (("".equals(result) ? "" : "且") + "满" + num + "件");
        }
        if ("".equals(result)) {
            return "无优惠";
        }
        result += ",";
        boolean flag = false;
        if (total != null && total.doubleValue() != 0) {
            flag = true;
            result += "总价" + (total.doubleValue() > 0 ? "减" : "加") + (total.doubleValue() > 0 ? total.doubleValue() : -total.doubleValue()) + "元";
        }
        if (price != null && price.doubleValue() != 0) {
            if (flag) {
                result += ",";
            }
            result += "单价" + (price.doubleValue() > 0 ? "减" : "加") + (price.doubleValue() > 0 ? price.doubleValue() : -price.doubleValue()) + "元";
        }
        return result;
    }

	public BigDecimal getMoney() {
		return money;
	}

	public void setMoney(BigDecimal money) {
		this.money = money;
	}

	public Integer getNum() {
		return num;
	}

	public void setNum(Integer num) {
		this.num = num;
	}

	public BigDecimal getTotal() {
		return total;
	}

	public void setTotal(BigDecimal total) {
		this.total = total;
	}

	public BigDecimal getPrice() {
		return price;
	}

	public void setPrice(BigDecimal price) {
		this.price = price;
	}
    
}
